package com.ewo.controller.ApplicationPageController;

import com.ewo.entity.ApplicationPage.CustomerSettlement;
import com.ewo.entity.ApplicationPage.EmployeeSettlement;
import com.ewo.entity.ResponseResult;
import com.ewo.service.ApplicationPage.CustomerSettlementService;
import com.ewo.service.ApplicationPage.EmployeeSettlementService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/settlement")
@CrossOrigin("*")
public class EmployeeSettlementController {

    @Resource
    EmployeeSettlementService employeeSettlementService;

    //根据员工id查找关联员工结算
    @GetMapping("/findESe/{empId}")
    public ResponseResult findEmployeeSettlementByEmpId(@PathVariable int empId) {
        List<EmployeeSettlement> employeeSettlementList = employeeSettlementService.findEmployeeSettlementByEmpId(empId);
        if (employeeSettlementList == null || employeeSettlementList.size() == 0) {
            return ResponseResult.fail();
        }
        return ResponseResult.ok(employeeSettlementList);
    }

    //根据工单id查找当前结算工单信息
    @GetMapping("/findOneESe/{empId}/{es_id}")
    public ResponseResult findEmployeeSettlementByESid(@PathVariable int empId,@PathVariable("es_id") int es_id){
        EmployeeSettlement employeeSettlement = employeeSettlementService.findEmployeeSettlementByESid(empId, es_id);
        return employeeSettlement==null ? ResponseResult.fail():ResponseResult.ok(employeeSettlement);
    }

}
